
import 'package:yp/services/api.dart';
import 'package:get/get.dart';
import 'package:sp_util/sp_util.dart';

import 'state.dart';

class MembershipInterestsLogic extends GetxController {
  final state = MembershipInterestsState();

  @override
  void onInit() {
    super.onInit();
    var params = {
      "use_platform": 2,
      "access_token": SpUtil.getString('token'),
      "system": "membership",
    };
    Api.membershipInterests(params).listen((event) {
      print('回去卡号 返回数据  event = $event');
      if (event['code'] == 0) {
        List list = event['info_list'];
        if (list.length > 0) {
          state.listMap = list;
        } else {
          state.listMap = [];
        }
      }
      update();
    });
  }

  // 下拉 刷新
  void refreshData() {
    state.listMap = [];
    var params = {
      "use_platform": 2,
      "access_token": SpUtil.getString('token'),
      "system": "membership",
    };
    Api.membershipInterests(params).listen((event) {
      print('回去卡号 返回数据  event = $event');
      if (event['code'] == 0) {
        List list = event['info_list'];
        if (list.length > 0) {
          state.listMap = list;
        } else {
          state.listMap = [];
        }
      }
      state.controller1.refreshCompleted();
      update();
    });
  }


}